package org.dromara.mall.controller;

import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.web.core.BaseController;
import org.dromara.mall.domain.vo.TurnoverVo;
import org.dromara.mall.service.IMallOrdersService;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

/**
 * package:TotalController
 *
 * @author MrLei QQ:235921049
 * desc:统计汇总
 * @Date 2024.08.28 20:12
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/mall/total")
public class TotalController extends BaseController {
    private final IMallOrdersService ordersService;

    /*根据日期营业额统计*/
    @GetMapping("/tenant")
    public R<TurnoverVo> tenantTotal (@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
                                      @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end) {
        return R.ok(ordersService.selectTenantByDate(begin,end));

    }
}
